package com.zhuang.arraylist.arraytest;

import java.util.concurrent.CopyOnWriteArrayList;

//线程任务类
class CollectionThread implements Runnable {
	// private static ArrayList<String> list = new ArrayList<String>();
	private static CopyOnWriteArrayList<String> list = new CopyOnWriteArrayList<String>();
	static {
		list.add("Jack");
		list.add("Lucy");
		list.add("Jimmy");
	}

	@Override
	public void run() {
		for (String value : list) {
			System.out.println(value);
			// 在读取数据的同时又向集合写入数据
			list.add("coco");
		}
	}
}